


CC=sdcc
NO_OPT=--nogcse --noinvariant --noinduction --nojtbound --noloopreverse --nolabelopt --nooverlay --peep-asm
DEBUG=--debug



INCLDUE_DIR += -I. -I./BspLib/include -I./OS/include -I./UserApp/include

CFLAGS=- $(INCLDUE_DIR)\
		-DSDCC_CYGNAL $(DEBUG) --xram-size 6000 \
		--model-large  -mmcs51 --stack-auto \
		--no-peep --int-long-reent --float-reent

BSP_DIR = BspLib
OS_DIR = OS
USER_DIR = UserApp

SRC	= \
$(USER_DIR)/main.c \
$(USER_DIR)/delay.c \
\
$(BSP_DIR)/USART.c \
$(BSP_DIR)/GPIO.c \
$(BSP_DIR)/timer.c \
\
$(OS_DIR)/common/heap_1.c \
$(OS_DIR)/tasks.c \
$(OS_DIR)/queue.c \
$(OS_DIR)/list.c \
$(OS_DIR)/port.c \
$(OS_DIR)/timers.c 

# Define all object files.
OBJ = $(SRC:%.c=build/%.rel)



build/app.hex:setenv build/main.ihx
	packihx build/main.ihx >  $@


build/main.ihx :  $(OBJ)
	$(CC) $(CFLAGS)  $(OBJ) -o $@ 

build/%.rel : %.c  
	$(CC) -c $(CFLAGS) $< -o $@ 

setenv:
	echo "set current enviroment"
	mkdir -p build
	mkdir -p build/BspLib
	mkdir -p build/OS
	mkdir -p build/OS/common
	mkdir -p build/UserApp

clean:
	rm -fr build/*




	


